set scheme s2color

* Figure 2(a)

local nocolumns 8
local nocolumns_m1 = `nocolumns'-1
clear
local new = _N + 1
set obs `new'
gen year = 0
expand `nocolumns_m1'
gen variable = _n+1
tempfile temp0
save `temp0.dta', replace

insheet using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A10.txt", tab clear
drop if _n<=3
drop if _n>16
forval i = 2/`nocolumns'{
	replace v`i' = subinstr(v`i',"*","",.)
	replace v`i' = subinstr(v`i',"(","",.)
	replace v`i' = subinstr(v`i',")","",.)
}
destring v2-v`nocolumns', replace
gen coefficient = (v1!="")
carryforward v1, replace
tempfile temp1
save `temp1.dta', replace

keep if coefficient==1
rename v1 time
reshape long v, i(time) j(variable)
drop coefficient
rename v coefficient
tempfile temp2
save `temp2.dta', replace

use `temp1.dta', clear
keep if coefficient==0
rename v1 time
reshape long v, i(time) j(variable)
drop coefficient
rename v stderr
merge 1:1 time variable using `temp2.dta', nogen
gen lb = coefficient - 1.96*stderr
gen ub = coefficient + 1.96*stderr

gen year = .
forval i = 1/4{
	replace year = -`i' if time =="m`i'"
	replace year = `i' if time =="p`i'"
}
append using `temp0.dta'
replace coefficient = 0 if year==0
replace lb = 0 if year==0
replace ub = 0 if year==0

drop if year==-4 | year==4

replace year = year - 0.125
gen nudge = year + 0.125
gen nudge2 = year + 0.25

sort variable year
graph twoway (scatter coefficient year if variable==4, msymbol(circle) mcolor(gs0)) (line coefficient year if variable==4, lcolor(gs0) lwidth(medthick)) (rcap ub lb year if variable==4, lcolor(gs0) lwidth(medthick)) (scatter coefficient nudge if variable==5, msymbol(diamond) mcolor(gs5) ) (line coefficient nudge if variable==5, lcolor(gs5) lpattern(longdash) lwidth(medthick)) (rcap ub lb nudge if variable==5, lcolor(gs5) lwidth(medthick) ) (scatter coefficient nudge2 if variable==6, msymbol(triangle) mcolor(gs10)) (line coefficient nudge2 if variable==6, lcolor(gs10) lpattern(dash) lwidth(medthick)) (rcap ub lb nudge2 if variable==6, lcolor(gs10) lwidth(medthick)), graphregion(color(white)) xline(0,lwidth(5) lcolor(gs14) lstyle(solid)) ytitle("Coefficient estimate" "", size(large)) xtitle("Year relative to merger", size(large))  ylabel(-0.5(0.25)0.5, labsize(large) gmax gmin) xlabel(-3 "-3" -2 "-2" -1 "-1" 0 "0" 1 "+1" 2 "+2" 3 "+3", labsize(large)) legend(order(1 "Sales{superscript:D,max}" 4 "Sales{superscript:D,med}  " 7 "Sales{superscript:D,min} ") size(large) pos(6) row(1) region(lcolor(black))) title("Baseline" " ", size(vlarge) color(black))
graph export "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\figure_2a.pdf", replace mag(100)

********************************************************************************

* Figure 2(b)

replace year = year + 0.125

sort variable year
graph twoway (scatter coefficient year if variable==7, msymbol(circle) mcolor(gs0)) (line coefficient year if variable==7, lcolor(gs0) lwidth(medthick)) (rcap ub lb year if variable==7, lcolor(gs0) lwidth(medthick)) , graphregion(color(white)) xline(0,lwidth(3) lcolor(gs14) lstyle(solid)) ytitle("Coefficient estimate" "", size(large)) xtitle("Year relative to merger", size(large)) ylabel(-0.05(0.05)0.15 , labsize(large) gmax gmin)  xlabel(-3 "-3" -2 "-2" -1 "-1" 0 "0" 1 "+1" 2 "+2" 3 "+3", labsize(large)) legend(order(1 "Skew{superscript:D}") size(large) pos(6) row(1) region(lcolor(black))) title("Baseline" " ", size(vlarge) color(black))
graph export "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\figure_2b.pdf", replace mag(100)

********************************************************************************

* Figure 2(c)

local nocolumns 7
local nocolumns_m1 = `nocolumns'-1
clear
local new = _N + 1
set obs `new'
gen year = 0
expand `nocolumns_m1'
gen variable = _n+1
tempfile temp0
save `temp0.dta', replace

insheet using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A11.txt", tab clear
drop if _n<=19
drop if _n>16
forval i = 2/`nocolumns'{
	replace v`i' = subinstr(v`i',"*","",.)
	replace v`i' = subinstr(v`i',"(","",.)
	replace v`i' = subinstr(v`i',")","",.)
}
destring v2-v`nocolumns', replace
gen coefficient = (v1!="")
carryforward v1, replace
tempfile temp1
save `temp1.dta', replace

keep if coefficient==1
rename v1 time
reshape long v, i(time) j(variable)
drop coefficient
rename v coefficient
tempfile temp2
save `temp2.dta', replace

use `temp1.dta', clear
keep if coefficient==0
rename v1 time
reshape long v, i(time) j(variable)
drop coefficient
rename v stderr
merge 1:1 time variable using `temp2.dta', nogen
gen lb = coefficient - 1.96*stderr
gen ub = coefficient + 1.96*stderr

gen year = .
forval i = 1/4{
	replace year = -`i' if time =="M`i'Xa"
	replace year = `i' if time =="P`i'Xa"
}
append using `temp0.dta'
replace coefficient = 0 if year==0
replace lb = 0 if year==0
replace ub = 0 if year==0

drop if year==-4 | year==4

replace year = year - 0.125
gen nudge = year + 0.125
gen nudge2 = year + 0.25

sort variable year
graph twoway (scatter coefficient year if variable==5, msymbol(circle) mcolor(gs0)) (line coefficient year if variable==5, lcolor(gs0) lwidth(medthick)) (rcap ub lb year if variable==5, lcolor(gs0) lwidth(medthick)) (scatter coefficient nudge if variable==6, msymbol(diamond) mcolor(gs5) ) (line coefficient nudge if variable==6, lcolor(gs5) lpattern(longdash) lwidth(medthick)) (rcap ub lb nudge if variable==6, lcolor(gs5) lwidth(medthick) ) (scatter coefficient nudge2 if variable==7, msymbol(triangle) mcolor(gs10)) (line coefficient nudge2 if variable==7, lcolor(gs10) lpattern(dash) lwidth(medthick)) (rcap ub lb nudge2 if variable==7, lcolor(gs10) lwidth(medthick)), graphregion(color(white)) xline(0,lwidth(5) lcolor(gs14) lstyle(solid)) ytitle("Coefficient estimate" "", size(large)) xtitle("Year relative to merger", size(large))  ylabel(-1(0.5)1, labsize(large) gmax gmin) xlabel(-3 "-3" -2 "-2" -1 "-1" 0 "0" 1 "+1" 2 "+2" 3 "+3", labsize(large)) legend(order(1 "Sales{superscript:D,max}" 4 "Sales{superscript:D,med}  " 7 "Sales{superscript:D,min} ") size(large) pos(6) row(1) region(lcolor(black))) title("Synthetic merger control group" " ", size(vlarge) color(black))
graph export "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\figure_2c.pdf", replace mag(100)

********************************************************************************

* Figure 2(d)

replace year = year + 0.125

sort variable year
graph twoway (scatter coefficient year if variable==4, msymbol(circle) mcolor(gs0)) (line coefficient year if variable==4, lcolor(gs0) lwidth(medthick)) (rcap ub lb year if variable==4, lcolor(gs0) lwidth(medthick)) , graphregion(color(white)) xline(0,lwidth(3) lcolor(gs14) lstyle(solid)) ytitle("Coefficient estimate" "", size(large)) xtitle("Year relative to merger", size(large)) ylabel(-0.1(0.1)0.2, labsize(large) gmax gmin)  xlabel(-3 "-3" -2 "-2" -1 "-1" 0 "0" 1 "+1" 2 "+2" 3 "+3", labsize(large)) legend(order(1 "Skew{superscript:D}") size(large) pos(6) row(1) region(lcolor(black))) title("Synthetic merger control group" " ", size(vlarge) color(black))
graph export "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\figure_2d.pdf", replace mag(100)
